home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993 April: Penguin on DISC / ADC Developer CD (1993-04) (''Penguin On DISC'')_iso / Dev.CD Apr 93.iso / Utilities / MPW Interfaces 7.1 Beta / PInterfaces / Components.p < prev    next >
Encoding:
Text File  |  1992-08-28  |  7.9 KB  |  246 lines  |  [TEXT/MPS ]

  1.  
  2. {
  3. Created: Wednesday, August 14, 1991 at 12:11 PM
  4.  Components.p
  5.  Pascal Interface to the Macintosh Libraries
  6.  
  7.  Copyright Apple Computer, Inc. 1990 - 1991
  8.  All rights reserved
  9.  
  10. }
  11.  
  12.  
  13. {$IFC UNDEFINED UsingIncludes}
  14. {$SETC UsingIncludes := 0}
  15. {$ENDC}
  16.  
  17. {$IFC NOT UsingIncludes}
  18.  UNIT Components;
  19.  INTERFACE
  20. {$ENDC}
  21.  
  22. {$IFC UNDEFINED UsingComponents}
  23. {$SETC UsingComponents := 1}
  24.  
  25. {$I+}
  26. {$SETC ComponentsIncludes := UsingIncludes}
  27. {$SETC UsingIncludes := 1}
  28. {$IFC UNDEFINED UsingTypes}
  29. {$I $$Shell(PInterfaces)Types.p}
  30. {$ENDC}
  31. {$SETC UsingIncludes := ComponentsIncludes}
  32.  
  33. CONST
  34. kAnyComponentType =            0;
  35. kAnyComponentSubType =         0;
  36. kAnyComponentManufacturer =    0;
  37. kAnyComponentFlagsMask =    0;
  38.  
  39. cmpWantsRegisterMessage = $80000000;
  40.  
  41.  
  42. TYPE
  43. ComponentDescription = RECORD
  44.  componentType: OSType;                                { A unique 4-byte code indentifying the command set }
  45.  componentSubType: OSType;                            { Particular flavor of this instance }
  46.  componentManufacturer: OSType;                        { Vendor indentification }
  47.  componentFlags: LONGINT;                            { 8 each for Component,Type,SubType,Manuf/revision }
  48.  componentFlagsMask: LONGINT;                        { Mask for specifying which flags to consider in search, zero during registration }
  49.  END;
  50.  
  51. ResourceSpec = RECORD
  52.  resType: OSType;                                    { 4-byte code  }
  53.  resId: INTEGER;                                    {    }
  54.  END;
  55.  
  56. ComponentResourcePtr = ^ComponentResource;
  57. ComponentResourceHandle = ^ComponentResourcePtr;
  58. ComponentResource = RECORD
  59.  cd: ComponentDescription;                            { Registration parameters }
  60.  component: ResourceSpec;                            { resource where Component code is found }
  61.  componentName: ResourceSpec;                        { name string resource }
  62.  componentInfo: ResourceSpec;                        { info string resource }
  63.  componentIcon: ResourceSpec;                        { icon resource }
  64.  END;
  65.  
  66. { Structure received by Component:  }
  67. ComponentParameters = PACKED RECORD
  68.  flags: CHAR;                                        { call modifiers: sync/async, deferred, immed, etc }
  69.  paramSize: CHAR;                                    { size in bytes of actual parameters passed to this call }
  70.  what: INTEGER;                                        { routine selector, negative for Component management calls }
  71.  params: ARRAY [0..0] OF LONGINT;                    { actual parameters for the indicated routine }
  72.  END;
  73.  
  74.  
  75. Component = ^ComponentRecord;
  76. ComponentRecord = RECORD
  77.  data: ARRAY [0..0] OF LONGINT;
  78.  END;
  79.  
  80. ComponentInstance = ^ComponentInstanceRecord;
  81. ComponentInstanceRecord = RECORD
  82.  data: ARRAY [0..0] OF LONGINT;
  83.  END;
  84.  
  85.  
  86.  
  87. ComponentResult = LONGINT;
  88.  
  89. ComponentRoutine = LONGINT;
  90.  
  91. ComponentFunction = LONGINT;
  92.  
  93.  
  94.  
  95. { *******************************************************
  96. *                                                     *
  97. *              APPLICATION LEVEL CALLS                *
  98. *                                                     *
  99. *******************************************************
  100. * Component Database Add, Delete, and Query Routines 
  101. *******************************************************
  102.  }
  103. FUNCTION RegisterComponent(cd: ComponentDescription;componentEntryPoint: ComponentRoutine;
  104.  global: INTEGER;componentName: Handle;componentInfo: Handle;componentIcon: Handle): Component;
  105.  INLINE $7001,$A82A;
  106. FUNCTION RegisterComponentResource(tr: ComponentResourceHandle;global: INTEGER): Component;
  107.  INLINE $7012,$A82A;
  108. FUNCTION UnregisterComponent(aComponent: Component): OSErr;
  109.  INLINE $7002,$A82A;
  110.  
  111. FUNCTION FindNextComponent(aComponent: Component;looking: ComponentDescription): Component;
  112.  INLINE $7004,$A82A;
  113. FUNCTION CountComponents(looking: ComponentDescription): LONGINT;
  114.  INLINE $7003,$A82A;
  115.  
  116. FUNCTION GetComponentInfo(aComponent: Component;cd: ComponentDescription;
  117.  componentName: Handle;componentInfo: Handle;componentIcon: Handle): OSErr;
  118.  INLINE $7005,$A82A;
  119. FUNCTION GetComponentListModSeed: LONGINT;
  120.  INLINE $7006,$A82A;
  121.  
  122.  
  123. { *******************************************************
  124. * Component Instance Allocation and dispatch routines 
  125. *******************************************************
  126.  }
  127. FUNCTION OpenComponent(aComponent: Component): ComponentInstance;
  128.  INLINE $7007,$A82A;
  129. FUNCTION CloseComponent(aComponentInstance: ComponentInstance): OSErr;
  130.  INLINE $7008,$A82A;
  131.  
  132. FUNCTION GetComponentInstanceError(aComponentInstance: ComponentInstance): OSErr;
  133.  INLINE $700A,$A82A;
  134.  
  135.  
  136. {  direct calls to the Components  }
  137. FUNCTION ComponentFunctionImplemented(ci: ComponentInstance;ftnNumber: INTEGER): LONGINT;
  138.  INLINE $2F3C,$2,$FFFD,$7000,$A82A;
  139. FUNCTION GetComponentVersion(ci: ComponentInstance): LONGINT;
  140.  INLINE $2F3C,$0,$FFFC,$7000,$A82A;
  141.  
  142. CONST
  143.  
  144. {****************************************************
  145. *                                                    *
  146. *               CALLS MADE BY Components             *
  147. *                                                    *
  148. ******************************************************
  149. ******************************************************
  150. * Required Component routines
  151. ******************************************************}
  152.  
  153. kComponentOpenSelect = -1;                            { ComponentInstance for this open }
  154. kComponentCloseSelect = -2;                            { ComponentInstance for this close }
  155. kComponentCanDoSelect = -3;                            { selector # being queried }
  156. kComponentVersionSelect = -4;                        { no params }
  157. kComponentRegisterSelect = -5;                        { no params }
  158. kComponentTargetSelect = -6;                        { ComponentInstance for top of call chain }
  159.  
  160.  
  161. { *******************************************************
  162. * Component Management routines
  163. *******************************************************
  164.  }
  165. PROCEDURE SetComponentInstanceError(aComponentInstance: ComponentInstance;
  166.  theError: OSErr);
  167.  INLINE $700B,$A82A;
  168.  
  169. FUNCTION GetComponentRefcon(aComponent: Component): LONGINT;
  170.  INLINE $7010,$A82A;
  171. PROCEDURE SetComponentRefcon(aComponent: Component;theRefcon: LONGINT);
  172.  INLINE $7011,$A82A;
  173.  
  174. FUNCTION OpenComponentResFile(aComponent: Component): INTEGER;
  175.  INLINE $7015,$A82A;
  176. FUNCTION CloseComponentResFile(refnum: INTEGER): OSErr;
  177.  INLINE $7018,$A82A;
  178.  
  179.  
  180. { *******************************************************
  181. * Component Instance Management routines
  182. *******************************************************
  183.  }
  184. FUNCTION GetComponentInstanceStorage(aComponentInstance: ComponentInstance): Handle;
  185.  INLINE $700C,$A82A;
  186. PROCEDURE SetComponentInstanceStorage(aComponentInstance: ComponentInstance;
  187.  theStorage: Handle);
  188.  INLINE $700D,$A82A;
  189.  
  190. FUNCTION GetComponentInstanceA5(aComponentInstance: ComponentInstance): LONGINT;
  191.  INLINE $700E,$A82A;
  192. PROCEDURE SetComponentInstanceA5(aComponentInstance: ComponentInstance;
  193.  theA5: LONGINT);
  194.  INLINE $700F,$A82A;
  195.  
  196. FUNCTION CountComponentInstances(aComponent: Component): LONGINT;
  197.  INLINE $7013,$A82A;
  198.  
  199. {  useful helper routines for convenient method dispatching  }
  200. FUNCTION CallComponentFunction(params: ComponentParameters;func: ComponentFunction): LONGINT;
  201.  INLINE $70FF,$A82A;
  202. FUNCTION CallComponentFunctionWithStorage(storage: Handle;params: ComponentParameters;
  203.  func: ComponentFunction): LONGINT;
  204.  INLINE $70FF,$A82A;
  205. FUNCTION DelegateComponentCall(originalParams: ComponentParameters;
  206.  ci: ComponentInstance): LONGINT;
  207.  INLINE $7024,$A82A;
  208.  
  209. CONST
  210.  
  211. { Set Default Component flags }
  212. defaultComponentIdentical = 0;
  213. defaultComponentAnyFlags = 1;
  214. defaultComponentAnyManufacturer = 2;
  215. defaultComponentAnySubType = 4;
  216. defaultComponentAnyFlagsAnyManufacturer = defaultComponentAnyFlags+defaultComponentAnyManufacturer;
  217. defaultComponentAnyFlagsAnyManufacturerAnySubType = defaultComponentAnyFlags+defaultComponentAnyManufacturer+defaultComponentAnySubType;
  218.  
  219. FUNCTION SetDefaultComponent(aComponent: Component;flags: INTEGER): OSErr;
  220.  INLINE $701E,$A82A;
  221. FUNCTION  OpenDefaultComponent(componentType: OSType; componentSubType: OSType ) : ComponentInstance;
  222.  INLINE $7021,$A82A;
  223. FUNCTION CaptureComponent(capturedComponent: Component;capturingComponent: Component): Component;
  224.  INLINE $701C,$A82A;
  225. FUNCTION UncaptureComponent(aComponent: Component): OSErr;
  226.  INLINE $701D,$A82A;
  227.  
  228.  
  229. CONST
  230.  
  231. { errors from component manager & components }
  232. invalidComponentID = -3000;
  233. validInstancesExist = -3001;
  234. componentNotCaptured = -3002;
  235. componentDontRegister = -3003;
  236.  
  237. badComponentInstance = $80008001;
  238. badComponentSelector = $80008002;
  239.  
  240. {$ENDC} { UsingComponents }
  241.  
  242. {$IFC NOT UsingIncludes}
  243.  END.
  244. {$ENDC}
  245.  
  246.